home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / sm_archv.zip / EAT-MON.ADA < prev    next >
Text File  |  1992-09-30  |  6KB  |  250 lines

  1. with  SMALL_SP;
  2. use  SMALL_SP;
  3. procedure EAT is
  4.  
  5.     task SCREEN is
  6.       entry SEIZE;
  7.       entry RELEASE;
  8.     end SCREEN;
  9.  
  10.     task DIJKSTRA is
  11.       entry GIVE_BIRTH;
  12.     end DIJKSTRA;
  13.  
  14.     task LISKOV is
  15.       entry GIVE_BIRTH;
  16.     end LISKOV;
  17.  
  18.     task SAMMET is
  19.       entry GIVE_BIRTH;
  20.     end SAMMET;
  21.  
  22.     task GEHANI is
  23.       entry GIVE_BIRTH;
  24.     end GEHANI;
  25.  
  26.     task CHOPSTICK1 is
  27.       entry PICKUP;
  28.       entry PUTDOWN;
  29.     end CHOPSTICK1;
  30.  
  31.     task CHOPSTICK2 is
  32.       entry PICKUP;
  33.       entry PUTDOWN;
  34.     end CHOPSTICK2;
  35.  
  36.     task CHOPSTICK3 is
  37.       entry PICKUP;
  38.       entry PUTDOWN;
  39.     end CHOPSTICK3;
  40.  
  41.     task CHOPSTICK4 is
  42.       entry PICKUP;
  43.       entry PUTDOWN;
  44.     end CHOPSTICK4;
  45.  
  46.   NO_MEALS : integer := 3;
  47.  
  48.     task body DIJKSTRA is
  49.        LENGTH_OF_MEAL: FLOAT;
  50.     begin
  51.         accept GIVE_BIRTH do
  52.           SCREEN.SEIZE;
  53.           PUT("Eddy Dijkstra living and breathing");
  54.           NEW_LINE;
  55.           SCREEN.RELEASE;
  56.         end GIVE_BIRTH;
  57.       for x in 1..NO_MEALS loop
  58.         CHOPSTICK1.PICKUP;
  59.         CHOPSTICK2.PICKUP;
  60.         LENGTH_OF_MEAL := RANDOM(9) + 1;
  61.         SCREEN.SEIZE;
  62.         PUT("Eddy Dijkstra eating meal"); PUT(x:2);
  63.         PUT(" with chopsticks 1 and 2");
  64.         PUT(" for"); PUT(LENGTH_OF_MEAL:2:0); PUT(" seconds");
  65.         NEW_LINE;
  66.         SCREEN.RELEASE;
  67.         delay LENGTH_OF_MEAL;
  68.         SCREEN.SEIZE;
  69.         PUT("Eddy Dijkstra done");
  70.         NEW_LINE;
  71.         SCREEN.RELEASE;
  72.         CHOPSTICK1.PUTDOWN;
  73.         CHOPSTICK2.PUTDOWN;
  74.         delay 5.0;
  75.       end loop;
  76.       SCREEN.SEIZE;
  77.       PUT("Eddy Dijkstra burp");
  78.       NEW_LINE;
  79.       SCREEN.RELEASE;
  80.     end DIJKSTRA;
  81.  
  82.     task body LISKOV is
  83.         LENGTH_OF_MEAL: FLOAT;
  84.     begin
  85.         accept GIVE_BIRTH do
  86.           SCREEN.SEIZE;
  87.           PUT(" Barbie Liskov living and breathing");
  88.           NEW_LINE;
  89.           SCREEN.RELEASE;
  90.         end GIVE_BIRTH;
  91.       for x in 1..NO_MEALS loop
  92.         CHOPSTICK2.PICKUP;
  93.         CHOPSTICK3.PICKUP;
  94.         LENGTH_OF_MEAL := RANDOM(9) + 1;
  95.         SCREEN.SEIZE;
  96.         PUT(" Barbie Liskov eating meal"); PUT(x:2);
  97.         PUT(" with chopsticks 2 and 3");
  98.         PUT(" for"); PUT(LENGTH_OF_MEAL:2:0); PUT(" seconds");
  99.         NEW_LINE;
  100.         SCREEN.RELEASE;
  101.         delay LENGTH_OF_MEAL;
  102.         SCREEN.SEIZE;
  103.         PUT(" Barbie Liskov done");
  104.         NEW_LINE;
  105.         SCREEN.RELEASE;
  106.         CHOPSTICK2.PUTDOWN;
  107.         CHOPSTICK3.PUTDOWN;
  108.         delay 5.0;
  109.       end loop;
  110.       SCREEN.SEIZE;
  111.       PUT(" Barbie Liskov burp");
  112.       NEW_LINE;
  113.       SCREEN.RELEASE;
  114.     end LISKOV;
  115.  
  116.     task body SAMMET is
  117.         LENGTH_OF_MEAL: FLOAT;
  118.     begin
  119.         accept GIVE_BIRTH do
  120.           SCREEN.SEIZE;
  121.           PUT("  Jeannie Sammet living and breathing");
  122.           NEW_LINE;
  123.           SCREEN.RELEASE;
  124.         end GIVE_BIRTH;
  125.       for x in 1..NO_MEALS loop
  126.         CHOPSTICK3.PICKUP;
  127.         CHOPSTICK4.PICKUP;
  128.         LENGTH_OF_MEAL := RANDOM(9) + 1;
  129.         SCREEN.SEIZE;
  130.         PUT("  Jeannie Sammet eating meal"); PUT(x:2);
  131.         PUT(" with chopsticks 3 and 4");
  132.         PUT(" for"); PUT(LENGTH_OF_MEAL:2:0); PUT(" seconds");
  133.         NEW_LINE;
  134.         SCREEN.RELEASE;
  135.         delay LENGTH_OF_MEAL;
  136.         SCREEN.SEIZE;
  137.         PUT("  Jeannie Sammet done");
  138.         NEW_LINE;
  139.         SCREEN.RELEASE;
  140.         CHOPSTICK3.PUTDOWN;
  141.         CHOPSTICK4.PUTDOWN;
  142.         delay 5.0;
  143.       end loop;
  144.       SCREEN.SEIZE;
  145.       PUT("  Jeannie Sammet burp");
  146.       NEW_LINE;
  147.       SCREEN.RELEASE;
  148.     end SAMMET;
  149.  
  150.     task body GEHANI is
  151.         LENGTH_OF_MEAL : FLOAT;
  152.     begin
  153.         accept GIVE_BIRTH do
  154.           SCREEN.SEIZE;
  155.           PUT("   Narain Gehani living and breathing");
  156.           NEW_LINE;
  157.           SCREEN.RELEASE;
  158.         end GIVE_BIRTH;
  159.       for x in 1..NO_MEALS loop
  160.         CHOPSTICK1.PICKUP;
  161.         CHOPSTICK4.PICKUP;
  162.         LENGTH_OF_MEAL := RANDOM(9) + 1;
  163.         SCREEN.SEIZE;
  164.         PUT("   Narain Gehani eating meal"); PUT(x:2);
  165.         PUT(" with chopsticks 1 and 4");
  166.         PUT(" for"); PUT(LENGTH_OF_MEAL:2:0); PUT(" seconds");
  167.         NEW_LINE;
  168.         SCREEN.RELEASE;
  169.         delay LENGTH_OF_MEAL;
  170.         SCREEN.SEIZE;
  171.         PUT("   Narain Gehani done");
  172.         NEW_LINE;
  173.         SCREEN.RELEASE;
  174.         CHOPSTICK1.PUTDOWN;
  175.         CHOPSTICK4.PUTDOWN;
  176.         delay 5.0;
  177.       end loop;
  178.       SCREEN.SEIZE;
  179.       PUT("   Narain Gehani burp");
  180.       NEW_LINE;
  181.       SCREEN.RELEASE;
  182.     end GEHANI;
  183.  
  184.     task body SCREEN is
  185.     begin
  186.       loop
  187.         select
  188.           accept SEIZE;
  189.           accept RELEASE;
  190.         or
  191.           terminate;
  192.         end select;
  193.       end loop;
  194.     end SCREEN;
  195.  
  196.     task body CHOPSTICK1 is
  197.     begin
  198.       loop
  199.         select
  200.           accept PICKUP;
  201.           accept PUTDOWN;
  202.         or
  203.           terminate;
  204.         end select;
  205.       end loop;
  206.     end CHOPSTICK1;
  207.  
  208.     task body CHOPSTICK2 is
  209.     begin
  210.       loop
  211.         select
  212.           accept PICKUP;
  213.           accept PUTDOWN;
  214.         or
  215.           terminate;
  216.         end select;
  217.       end loop;
  218.     end CHOPSTICK2;
  219.  
  220.     task body CHOPSTICK3 is
  221.     begin
  222.       loop
  223.         select
  224.           accept PICKUP;
  225.           accept PUTDOWN;
  226.         or
  227.           terminate;
  228.         end select;
  229.       end loop;
  230.     end CHOPSTICK3;
  231.  
  232.     task body CHOPSTICK4 is
  233.     begin
  234.       loop
  235.         select
  236.           accept PICKUP;
  237.           accept PUTDOWN;
  238.         or
  239.           terminate;
  240.         end select;
  241.       end loop;
  242.     end CHOPSTICK4;
  243.  
  244. begin
  245.   DIJKSTRA.GIVE_BIRTH;
  246.   LISKOV.GIVE_BIRTH;
  247.   SAMMET.GIVE_BIRTH;
  248.   GEHANI.GIVE_BIRTH;
  249. end EAT;
  250.